table.insert(itemActions,
	function(item, action)
		-- MAGIC jewels
		-- see: dir .. "readme.txt" for information regarding these variables
		local priority = 6
		local identify = true -- change to false if you want to keep ALL jewels
		local dump = true

		if not (item.quality == ItemQuality.Magic and item.baseItem.code == "jew") then
			return false
		elseif action == aPICK and (not item.flags.Identified or isGoodMagicJewel(item)) then
			return priority
		elseif action == aIDENT then
			return identify
		elseif action == aSELL and item.flags.Identified and not isGoodMagicJewel(item) then
			return true
		elseif action == aDUMP and item.flags.Identified and not isGoodMagicJewel(item) then
			return dump
		end

		return false
	end
)

function isGoodMagicJewel(item)
	-- note: edam, mp, str, dex, eng, and hp are all assigned values
	-- so you can add custom jewels in the return
	-- do not try to compare other variables (bools) with numbers
	-- feel free to change the lower prefix/suffix bounds
	local prefix = false
	local edam, mp = 0, 0
	local suffix = false
	local str, ar, dex, dtm, def, eng, hp, ias, fhr, mindmg, req = 0, 0, 0, 0, 0, 0, 0, false, false, false, false
	local affix = false
	
	if hasRes(item, 11, 4) or hasRes(item, 20, 1) then -- 11-14 allres or 20-29 singleres->prefix
		prefix = true
	end

	if hasRes(item, 15, 4) or hasRes(item, 30, 1) then -- 15 allres or 30 singleres ->affix
		affix = true
	end

	for i = 0, item.mods:size() - 1 do
		if item.mods[i].Stat.Type == StatType.MaxDamagePercent then
			 if item.mods[i].Value >= 30 then -- 30+edam->prefix
				prefix = true
			elseif item.mods[i].Value == 40 then -- 40 edam->affix
				affix = true
			end
			edam = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.MaxMana then
			 if item.mods[i].Value >= 16 then -- 16+mp->prefix
				prefix = true
			end
			mp = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.ArmorClass then
			 if item.mods[i].Value >= 60 then -- 60-64 def->prefix -- ivory
				prefix = true
			end
			def = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.DamageToMana then
			 if item.mods[i].Value >= 7 then -- 7-12% dmg to mana->prefix -- dun
				prefix = true
			end
			dtm = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.Strength then
			 if item.mods[i].Value >= 7 then -- 7-9 str->suffix
				suffix = true
			end
			str = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.Dexterity then
			 if item.mods[i].Value >= 7 then -- 7-9 dex->suffix
				suffix = true
			end
			dex = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.Energy then
			 if item.mods[i].Value >= 7 then -- 7-9 eng->suffix
				suffix = true
			end
			eng = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.MaxLife then
			 if item.mods[i].Value >= 16 then -- 16-20 hp->suffix
				suffix = true
			end
			hp = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.MinDamage then
			 if item.mods[i].Value >= 8 then -- 8-10 minimum damage->suffix
				suffix = true
			end
		elseif item.mods[i].Stat.Type == StatType.LightMaxDamage then
			 if item.mods[i].Value >= 61 then -- 61-100 lite dmg->suffix
				suffix = true
			end
		elseif item.mods[i].Stat.Type == StatType.FasterAttackRate then
			ias = true -- ias->suffix
			suffix = true
		elseif item.mods[i].Stat.Type == StatType.FasterHitRecovery then
			fhr = true -- fhr->suffix
			suffix = true
		elseif item.mods[i].Stat.Type == StatType.LowerRequirementsPercent then
			req = true -- req->suffix
			suffix = true
		end
	end
	
	return (
			(ias and edam >= 30) or -- custom jewel example 15% ias 30-39% ED
			(prefix and suffix) or
			(ias or req) and (prefix or suffix) or
			affix
			)
end